﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using TangGuo.Resources;

namespace TangGuo.UserControls
{
    /// <summary>
    /// TangGuoMapBox.xaml 的交互逻辑
    /// </summary>
    public partial class TangGuoMapBox : UserControl
    {
        public int Col, Row;
        public TangGuoMapBox()
        {
            InitializeComponent();
        }

        private void MapBox_MouseDown(object sender, MouseButtonEventArgs e)
        {
            PublicData.IsTangGuoBlankSelect = true;
            PublicData.TangGuoBlankSelectedCol = Col;
            PublicData.TangGuoBlankSelectedRow = Row;
            PublicData.IsTangGuoSelect = false;
        }
        public void SetPos(int x, int y)
        {
            Col = x;
            Row = y;
            double xd = (y % 2) == 0 ? x * 90.0 : 45.0 + x * 90.0;
            double yd = y * 77;
            SetValue(Canvas.LeftProperty, xd);
            SetValue(Canvas.TopProperty, yd);
            if (Col == 6 && Row % 2 == 1) { SetHidden(); }
        }
        public void SetHidden()
        {
            Visibility = Visibility.Hidden;
        }
        public void SetVisible()
        {
            if (Col == 6 && Row % 2 == 1) return;
            Visibility = Visibility.Visible;
        }
        public BasePos GetBasePos()
        {
            return new BasePos(Col, Row);
        }
    }
}
